package com.billdowney.security.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Service;

import com.billdowney.util.http.HttpIOUtil;
import com.billdowney.util.return_type.ReturnData;

/**
 * 自定义权限不足处理程序
 * 
 * @author 超级小富翁 - BillDowney
 * @date 2019年2月27日 下午4:39:26
 */
@Service
public class CustomAccessDeniedHandler implements AccessDeniedHandler {

	@Override
	public void handle(HttpServletRequest request, HttpServletResponse response,
			AccessDeniedException accessDeniedException) throws IOException, ServletException {
		HttpIOUtil.outJsonData(response, new ReturnData(accessDeniedException));
		accessDeniedException.printStackTrace();
	}

}
